﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace NASA.BeAMartian.Execution
{
    public class ActionExecutionItem : ExecutionItem
    {
        public ActionExecutionItem(Action action)
        {
            this.Action = action;
        }

        public override void Invoke()
        {
            Exception ex = null;

            try
            {
                this.Action();
            }
            catch (Exception e)
            {
                ex = e;
            }

            this.OnActionCompleted(ex, this.IsCanceled);
        }

        public Action Action { get; set; }
    }
}
